package Test;

import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.*;


public class TestDemo5 {
    public static void main(String[] args) {
        HashMap<String,Integer> hashMap = new HashMap<>();
        Hashtable<String,Integer> hashtable = new Hashtable<>();
        hashMap.put("123",123);
        hashtable.put("456",456);
        System.out.println(Runtime.getRuntime().availableProcessors());
        String str = "123";
        String str1 = "23";
        System.out.println(str1.equals(str));
    }
    public static void main5(String[] args) {
        List<Integer> list = new ArrayList<>();
        HashSet<Integer> hashSet = new HashSet<>();
        hashSet.add(1);
        list.add(1);
        Iterator<Integer> iterator = list.iterator();
        while (iterator.hasNext()) {
            int num = iterator.next();
            System.out.println(num);
        }

    }
    public static void main4(String[] args) throws NoSuchFieldException, IllegalAccessException {
        String str = "hello";
        System.out.println(str);
        Class<? extends String> aClass = str.getClass();
        Field value = aClass.getDeclaredField("value");
        value.setAccessible(true);
        char[] o = (char[]) value.get(str);
        o[0] = 'g';
        System.out.println(str);
        HashMap<Integer,String> hashMap = new HashMap<>();
        HashSet<Integer> hashSet = new HashSet<>();
    }
    public static void main3(String[] args) throws CloneNotSupportedException {
        CloneTest cloneTest = new CloneTest("张三");
        CloneTest cloneTest1 = (CloneTest) cloneTest.clone();
        cloneTest1.setName("李四");
        System.out.println(cloneTest);
        System.out.println(cloneTest1);

    }
    public static void main2(String[] args) {
        Out out = new Out("123");
        Out.Inner inner = out.new Inner();
        inner.func();
        System.out.println(inner.getClass());

    }
    public static void main1(String[] args) throws ClassNotFoundException, NoSuchFieldException {
        double f1 = 0.0;
        double f2 = 3.14;
        double f3 = f1+f2;
        double f4 = 0.3;
        BigDecimal sum1 = new BigDecimal(2.3);
        String str = "true";
        switch (str) {
            case "true" :
                System.out.println("true");
                break;
            case "false" :
                System.out.println("false");
                break;
        }
        System.out.println("f3   "+f3);
        System.out.println("f4   "+f4);
        if(f3 == f4) {
            System.out.println("等于");
        } else {
            System.out.println("不等于");
        }
    }


}
class Out{
    private String str;

    public Out(String str) {
        this.str = str;
    }

    class Inner{
        public void func() {
            System.out.println("hello");
        }
    }
}

class CloneTest implements Cloneable{
    private String name;

    public CloneTest(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "CloneTest{" +
                "name='" + name + '\'' +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        CloneTest cloneTest = (CloneTest) o;
        return Objects.equals(name, cloneTest.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name);
    }
}